package master;

import javax.swing.table.AbstractTableModel;
import java.util.ArrayList;
import java.util.List;

public class EmployerTableModel extends AbstractTableModel {
    private final String[] columnNames = {"编码", "姓名", "岗位", "部门编号", "密码"};
    private List<Employer> employers = new ArrayList<>();
    public int getRowCount() {
        return employers.size();
    }
    public int getColumnCount() {
        return columnNames.length;
    }
    public Object getValueAt(int rowIndex, int columnIndex) {
        Employer employer = employers.get(rowIndex);
        switch (columnIndex) {
            case 0:
                return employer.getEmpno();
            case 1:
                return employer.getEname();
            case 2:
                return employer.getJob();
            case 3:
                return employer.getDeptno();
            case 4:
                return employer.getPassword();
            default:
                return null;
        }
    }

    public void setEmployers(List<Employer> employers) {
        this.employers = employers;
    }
}
